home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1997 April / PC Direct CD-ROM (April 1997).iso / FAXMAKER / MACROS / WORDPRO / OTGFIFAX.LSS next >
Encoding:
Text File  |  1996-07-19  |  2.7 KB  |  91 lines

  1. Option Public
  2.  
  3. Sub Main
  4.     
  5. '    OfficeTalk Fax Merge Macro v1.0 (Word Pro, Tested Release N70.941.0)
  6. '    -------------------------------------
  7. '    Written By Karl Flower & Greg Carrell
  8. '    (c) Sareen Software Plc 1996
  9. '    Created On 17th July 1996
  10. '    Modified On 18th July 1996
  11. '    -------------------------------------
  12.     
  13. '    Find and read GFI FAX input string and handle errors
  14.     .Application.FindAndReplace.FindString = "/$FAX"
  15.     .Application.FindAndReplace.ReplaceString = ""
  16.     .Application.FindAndReplace.MatchType = $LwpFindMatchWithinAWord
  17.     FOUND = .Find()
  18.     .InitFindAndReplace True
  19.     
  20.     If FOUND <> 0 Then
  21.         Messagebox "No appropriate Fax Tag was found!", 48, "OT Fax Macro Error"
  22.         Exit Sub
  23.     End If
  24.     
  25. '    Extract fax info from GFI FAX input string and handle errors
  26.     
  27.     GFISTRING$ = .Text.GetText($LwpGetObjectTypeParagraph, False)
  28.     ORIGSTRING$ = GFISTRING$    
  29.     
  30.     If Mid$(GFISTRING$, 1, 5) = "GFI$/" Then
  31.         
  32.         GFISTRING$ = Mid$(GFISTRING$, 6, Len(GFISTRING$) - 5)
  33.         GFISTRING$ = Left$(GFISTRING$, Len(GFISTRING$) - 5)
  34.         
  35.         CURRMARK = Instr(1, GFISTRING$, "/$/")
  36.         If CURRMARK <> 0 Then
  37.             FAXNO$ = Left$(GFISTRING$, CURRMARK - 1)
  38.             GFISTRING$ = Mid$(GFISTRING$, CURRMARK + 3, Len(GFISTRING$) - CURRMARK + 3)
  39.         Else
  40.             FAXNO$ = GFISTRING$
  41.             GFISTRING$ = ""
  42.             CONTACT$ = ""
  43.             COMPANY$ = ""
  44.         End If
  45.         
  46.         CURRMARK = Instr(1, GFISTRING$, "/$/")
  47.         If CURRMARK <> 0 Then
  48.             CONTACT$ = Left$(GFISTRING$, CURRMARK - 1)
  49.             GFISTRING$ = Mid$(GFISTRING$, CURRMARK + 3, Len(GFISTRING$) -     CURRMARK + 3)
  50.             COMPANY$ = GFISTRING$
  51.         Else
  52.             CONTACT$ = GFISTRING$
  53.             COMPANY$ = ""
  54.         End If
  55.         
  56.     Else
  57.         Messagebox "The Fax Tag is not correctly constructed!", 48, "OT Fax Macro Error"
  58.         Exit Sub
  59.     End If
  60.     
  61. '    Remove fax info string from document
  62.     .Type("[END]")
  63.     .TYPE("[SHIFTUP]")
  64.     .Type("[DEL]")
  65.     
  66. '    Read default printer information
  67.     PRINTER$ = .ActiveDocument.PrintManager.PrinterName
  68.     PORT$ = .ActiveDocument.PrintManager.PrintDestination
  69.     
  70. '    Change current printer to FaxMaker and Print Document
  71.     .ActiveDocument.PrintManager.UseDefaultPrinter = False
  72.     .ActiveDocument.PrintManager.PrinterName = "FaxMaker"
  73.     .ActiveDocument.PrintManager.PrintDestination = "GFI"
  74.     .ActiveDocument.PrintManager.UpdatePrinterChanges
  75.     .Print
  76.     
  77. '    Wait for GFI Fax client to initiate and then pass fax info
  78.     CHANNEL = 0
  79.     While CHANNEL = 0
  80.         CHANNEL = DDEInitiate("FMCLIENT", "SENDFAX")
  81.     Wend
  82.     DDEPoke CHANNEL, "ADD", CONTACT$ + "|" + COMPANY$ + "|" + FAXNO$
  83.     DDETerminate(CHANNEL)
  84.     
  85. '    Set default printer back to original
  86.     .ActiveDocument.PrintManager.PrinterName = PRINTER$
  87.     .ActiveDocument.PrintManager.PrintDestination = PORT$
  88.     .ActiveDocument.PrintManager.UpdatePrinterChanges
  89.     
  90. End Sub
  91.